home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Technotools
/
Technotools (Chestnut CD-ROM)(1993).ISO
/
lang_c
/
bitstrg
/
crebitar.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-06-05
|
788b
|
36 lines
/*
librairie : bitstrg
crebitarray -- allocation memoire pour champ de bits
*/
#include <stdio.h>
#include "bitstrg.h"
/*
Creation of an array of bit
The array is initialized to all 0s
return a pointer on the array parameters structure or NULL if problem
*/
struct SPARRAY* crebitarray(nbbit)
unsigned nbbit; /* number of the last bit in the array */
{
unsigned value; /* number of element in array */
struct SPARRAY* pnt;
value = (((long)nbbit+1) / SIZE )
+ ((((long)nbbit+1) & (SIZE - 1)) ? 1 : 0);
if((pnt = (struct SPARRAY *) calloc (1,sizeof(struct SPARRAY))) != NULL) {
if((pnt->pntarray = (ELEBAR*) calloc(value,sizeof(ELEBAR))) == NULL) {
free(pnt);
return(NULL);
}
pnt->numlbit = nbbit;
}
return(pnt);
}